/*
package com.shen.demo.demos.web.service;

import com.shen.demo.demos.web.compont.MyWebSocketHandler;
import com.shen.demo.demos.web.domain.entry.UserName;
import org.springframework.beans.factory.annotation.Autowired;
   import org.springframework.stereotype.Service;
   import org.springframework.web.socket.TextMessage;
   import org.springframework.web.socket.WebSocketSession;


import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

@Service
public class DataPushService {

    private static final List<WebSocketSession> sessions = new CopyOnWriteArrayList<>();

    @Autowired
    private MyWebSocketHandler webSocketHandler;

    public static void addSession(WebSocketSession session) {
        sessions.add(session);
    }

    public static void removeSession(WebSocketSession session) {
        sessions.remove(session);
    }

    public static void pushData(UserName warehouseLocation) {
        String data = "Location Code: " + warehouseLocation.getName() + ", Description: " + warehouseLocation.getGrade();
        for (WebSocketSession session : sessions) {
            try {
                if (session.isOpen()) {
                    session.sendMessage(new TextMessage(data));
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

   */
